<template>
	<div class="reviewDetail">
		<div class="top">
			<div>{{review.title}}</div>
			<div>{{review.createTime}}</div>
		</div>
		<div class="content">
			<div >{{review.content}}</div>
			<div class="tip">评审文件</div>
			<div class="pdf el-icon-document" v-if="review.filename" @click="toReadPdf(review.enclosure)">
				{{review.filename}}
			</div>
			<!-- <div @click="toReadPdfa(review.enclosure)">{{review.filename}}</div> -->
			<div class="tip">评审意见</div>
			<template v-for="item in userZy">
				<div class="con" v-if="item.role==0 && (item.opinion==0 ||item.opinion==1)" >组长-{{item.truename}} : {{item.opinion==0?'已通过':'已驳回'}}</div>
				<div class="con" v-if="item.role==0 && item.content" >组长意见: {{item.content}}</div>
				<div class="con" v-else-if="item.role==1 && item.content">组员-{{item.truename}} : {{item.content}}</div>
			</template>
			<!-- -->
			<template v-if="state!=2 && user.accessId">
				<van-field
				style="border: 1px solid #ebedf0;"
				  v-model="textarea"
				  rows="3"
				  autosize
				  label=""
				  type="textarea"
				  placeholder="请输入意见"
				/>
				<div class="review flex_lr_m" v-if="user.role==0" style="margin-top: 12px;">
					 <!-- <el-button >驳回</el-button> -->
					 <van-button type="default" style="width: 45%;border-radius: 30px;" @click="toSubmit(1)">驳回</van-button>
					 <van-button type="default"  style="background-color: orange;border-radius: 30px; border-color: orange; color: #fff;width: 45%;" @click="toSubmit(0)">同意</van-button>
					 <!-- <el-button style="background-color: orange; border-color: orange; color: #fff;width: 45%;">同意</el-button> -->
				</div>
				<div class="review  flex_line_c"  v-else>
					
					  <van-button type="warning"  style="background-color: orange; border-color: orange; color: #fff;width: 100%;margin-top: 12px;" @click="toSubmit('')">提交</van-button>
				</div>
			</template>
			
		</div>
	</div>
</template>

<script >
	import request from "@/utils/request";
	import { MessageBox, Toast } from "mint-ui";
	export default {
		data(){
			return{
				review:{},
				user:{},
				userZy:[],
				role:'',
				state:'',
				textarea:'',
				submit:false,
			}
		},
		created(){
			this.role=this.$route.query.role
			this.state=this.$route.query.state
			this.reviewDetail()
			this.reviewUser()
		},
		 
		methods:{
			reviewUser(){
				request({
				  url: "/generator/accuser/front/info?accessId="+this.$route.query.row,
				  method: "get"
				}).then((response) => {
				  console.log(response.status);
				  if (response.code == 0) {
					this.user=response.accuser
				    this.userZy=response.list
					console.log(this.userZy)
				  }
				});
			},
			reviewDetail(name) {
			  request({
			    url: "/generator/access/front/info?id="+this.$route.query.row,
			    method: "get"
			  }).then((response) => {
			    console.log(response.status);
			    if (response.code == 0) {
			      this.review=response.access
			    }
			  });
			},
			toReadPdfa(url){
				window.location.href=url
			},
			toReadPdf(url){
				// console.log(1212)
				window.location.href=url
				// window.location.href='https://view.officeapps.live.com/op/view.aspx?src='+url
				// url='http://storage.xuetangx.com/public_assets/xuetangx/PDF/PlayerAPI_v1.0.6.pdf'
				// // url='https://demoee.oss-cn-shanghai.aliyuncs.com/point/1637291443839.pdf'
				// this.$router.push({ name: "readPdf", query: { row: encodeURIComponent(url)} });
			},
			toSubmit(opinions){
				if(this.submit) return
				this.submit=true
				this.user.opinion=opinions
				this.user.content=this.textarea,
				request({
				  url: "/generator/accuser/front/edit",
				  method: "post",
				  data:this.user
				}).then((response) => {
				  if (response.code == 200) {
					  Toast('提交评审成功！');
					this.$router.back(-1)
				  }else{
					  Toast("提交评审失败,请再试一次！")
					  this.submit=false
				  }
				});
			}
		}
	}
</script>

<style scoped="scoped">
	.reviewDetail{
		min-height: 100vh;
		color: #333;
		/* background-color: #f6f6f6; */
	}
	.top,
	.content{
		width: 100%;
		padding: 10px 24px;
		box-sizing: border-box;
	}
	.top>div:nth-child(1) {
		font-weight: bold;
		font-size: 18px;
		/* overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap; */
		margin-bottom: 8px;
	}
	.top>div:nth-child(2) ,
	.tip{
		font-size: 14px;
		color: #b9b9b9;
	}
	.tip{
		margin: 12px 0;
	}
	.top{
		border-bottom: 8px solid #f8f8f8;
	}
	.content>div:nth-child(1){
		font-size: 16px;
	}
	.con{
		font-size: 14rpx;
		margin-bottom: 8px;
	}
	.pdf{
		width: 100%;
		padding: 20px 12px;
		border-radius: 10px;
		border: #f8f8f8 solid 1px;
		box-shadow: #989898 4px 4px 7px -4px; 
		font-size: 16px;
	}
	.review{
	}
</style>
